import * as actionType from "./actionType"

const initState = {
  userId: "",
  username: "",
  token: "",
  branchName: "",
  permission: [],
  roleId: null,
  roleName: "",
  isLogin: false,
}



function reducer(state = initState, action) {
  switch (action.type) {
    case actionType.USER_LOGIN:
      return {
        ...state,
        ...action.user,
      }
    case actionType.USER_LOGOUT:
      return {
        userId: "",
        username: "",
        token: "",
        isLogin: false,
      }
    default:
      return state
  }
}

export default reducer
